<%@ page pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<script type="text/javascript">
$(function(){
	 var mygrid = $('#list').jqGrid({
	    	url:'admin/user/user!bydepartment',
	    	postData:{'department.id':'${param.deptId}'},
	        datatype: 'json',
	        mtype: 'GET',
	        colNames:['查看','登录名','状态','管理'],
	        colModel :[ 
	        {name:'username', index:'username', width:200, formatter:viewFormater}, 
	        {name:'username', index:'username', width:200},         
	        {name:'enabled', index:'enabled', width:200, formatter:statusFormatter},         
	        {name:'username', index:'username', width:200, formatter:removeFormatter}         
	      ],
	      pager:'#pager',
	      rowNum:10,
	      rowList:[5,10,20],
	      sortname: 'username',
	      sortorder: 'desc',
	      viewrecords: true,
	      caption: '用户列表',
	      width:'500',
	      height:'300',
	      jsonReader: {
	  		repeatitems : false,
	  		id: "0"
	  	  }
	    });
}); 



  function viewFormater(cellvalue,options,rowObject){
      var eid = rowObject['id'];
      var url = "admin/user/user!get?bean.username="+cellvalue;
      var link = $(getAjaxLink(url,rowObject['localName']));
      return $("<span></span>").append(link).html();

   }
   function removeFormatter(cellvalue ,options,rowObject){
   	var url = 'business/component!removeuser?bean.username='+cellvalue;
    var link=$(getAjaxMsgLink(url,'删除','这将删除该用户及关联的所有资料\n确认删除!'));
   	return $("<span></span>").append(link).html();
   }  
   
   function statusFormatter(cellvalue ,options,rowObject){
   	var chk = (cellvalue==true)?"checked":"";
   	var link = $("<input type='checkbox' "+chk+" disabled></input>");
   	return $("<span></span>").append(link).html();
   }   
</script>
<div id="jqgrid">
<table id="list"></table>
<div id="pager"></div>
</div>